<?php
class Model_DbTable_Time extends Zend_Db_Table_Abstract
{
	protected $_name = 'times';


	public function setTime( $timeObj )
	{
		//var_dump($timeObj);
		try{

		
                $data = array(
                'timefrom'=> $timeObj->getParam('timefrom'),
                'timeto'=> $timeObj->getParam('timeto'),
                'day'=>$timeObj->getParam('day'),
                'reserved'=>date("Y-m-d H:i:s"),
                'locationid'=> $timeObj->getParam('locationid'),
                'info'=> $timeObj->getParam('info')
                        );

		 return $this->insert($data);
		 
		} catch (Zend_Exception $e) { 
                echo  $e->getMessage();
			//error
			return -1; 	 	
		}
	}


        	public function getTime()
	{


		try{
		$select = $this->select()
		 ->from($this->_name, array(
                     "info as title",
                     "CONCAT(day,' ', timefrom) as start",
                     "CONCAT(day,' ', timeto) as end"                  
                     ))
		 //->joinInner('days','days.id = consultingdays.dayid', array('days'))
		 //->where('fromdays< ?', date("Y-m-d"))
		 //->where('consultingdays.id NOT IN(?)', $reservedrows)
		 ->order(array('day ASC'));

		 $select->setIntegrityCheck(false);
		// echo "<br> $select <br>";
		 $row = $this->fetchAll($select);
	 	 //  Zend_Debug::dump($rows);
	     return $row;

		} catch (Zend_Exception $e) {
            echo  $e->getMessage();
			//error
			return -1;
		}
	}
	

	

}